<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>变更RowKey</title>
<%@ include file="/pages/common/header.jsp" %>
 <script type="text/javascript" src="<%=request.getContextPath() %>/js/datePicker/WdatePicker.js"></script>
 <style type="text/css">
	.navbar{line-height:33px;height:33px;background:url('${pageContext.request.contextPath}/images/background/navbar.gif') repeat-x; width:100%; position:relative; margin-top:8px; margin-bottom:8px;}
		.navbar-l,.navbar-r{ width:2px;height:33px;background:url('${pageContext.request.contextPath}/images/background/navbar.gif') no-repeat; position:absolute; }
		.navbar-l{ left:0px; background-position:0px -33px;}
		.navbar-r{ right:0px;background-position:0px -66px;}
		.navbar-icon{ position:absolute; left:7px; top:6px;}
		.navbar img{ width:20px; height:20px;}
		.navbar-inner{ margin-left:30px;}
		.navbar a{ color:#3186C8;}
</style>

<script type="text/javascript">
	$(function(){
		$("#tableName").bind('change',function(){
			var tableName =$("#tableName").val();
			if(tableName== "CRAWL_PLANE_FREIGHT" || tableName=="CRAWL_PLANE_FREIGHT_DOUBLE"){
				$("#time_start").show();
				$("#time_end").show();
			}else{
				$("#time_start").hide();
				$("#time_end").hide();
			}
		});
	
	
	$("#btn1").bind('click',function(){
		var tableName =$("#tableName").val();
		var start =$("#start").val();
		var end =$("#end").val();
		if(tableName== "" || tableName==null || tableName=="undefined"){
			alert("请选 择要变更RowKey的Hbase表 ");
			return false;
		}
		if(tableName== "CRAWL_PLANE_FREIGHT" || tableName=="CRAWL_PLANE_FREIGHT_DOUBLE"){
				if(start == "" || start== "undefined"){
					alert("请选择开始时间");
					return false;
				}
				if(end == "" || end== "undefined"){
					alert("请选择结束时间");
					return false;
				}
				start=start.replace(/-/g,"").replace(/ /g,"");
				end=end.replace(/-/g,"").replace(/ /g,"");
				if(start>end){
					alert("开始时间不能大于结束时间");
					return false;
				}
		}
		$("#wait").show();
		$("#btn1").attr("disabled","true");
		var url ="<%=request.getContextPath() %>"+"/preprocess-ChaneRowKey-manualExecute.action";
		var data ={"start":start,"end":end,"tableName":tableName};
		 $.ajax({
				url:url,
				data:data,
				type : "POST",
				cache : false, 
				async : true,
			  //  dataType:'html',
			    beforeSend:function(){
			    },
			    success:function(data){
			    	alert("rowkey变更成功！");
			    	$("#btn1").removeAttr("disabled");
			    	$("#wait").hide();
			    },
			    error:function(){
			    	alert("rowkey变更失败！，请联系管理员！");
			    	$("#btn1").removeAttr("disabled");
			    	$("#wait").hide();
			    	},
			    	
			    complete:function(){ 
			    	$("#btn1").removeAttr("disabled");
			    	$("#wait").hide();
			    }
			});
	});
	
});
</script>

</head>
<body>
<div class="searchtitle" style="width :1100px;">
	<div class="navbar"><div class="navbar-l"></div><div class="navbar-r"></div>
	        <div class="navbar-inner"> 
	        <b>变更RowKey</b> 
	        </div>
	 </div>
	 <table cellSpacing=0 cellPadding=0  border=0 class="form2column">
		 <tr>
			<td class="label">Hbase表：</td>
			<td class="">
				<select name="tableName" id="tableName">
				<option value="">--请选择--</option>
				<option value="CRAWL_PLANE_FREIGHT">CRAWL_PLANE_FREIGHT</option>
				<option value="CRAWL_PLANE_FREIGHT_DOUBLE">CRAWL_PLANE_FREIGHT_DOUBLE</option>
				<option value="LP_FLIGHT_HISTORY">LP_FLIGHT_HISTORY</option>
				<option value="LP_FLIGHT_HISTORY_DOUBLE">LP_FLIGHT_HISTORY_DOUBLE</option>
				</select>
			</td>
			<td class=""></td>
			<td class=""></td>
		</tr>
		
			<tr id ="time_start" style="display:none;">
				<td class="label"> 开始日期：</td>
				<td class="" style="width:250px;">
					<input name="start" type="text"	id="start" style="width: 180px"    
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly"/>
				</td>
				<td class=""></td>
				<td class=""></td>
			</tr>
			<tr id ="time_end" style="display:none;">
				<td class="label"> 结束日期：</td>
				<td class="" style="width:250px;">
					<input name="end" type="text"	id="end" style="width: 180px"    
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly"/>
				</td>
				<td class=""></td>
				<td class=""></td>
			</tr>
		
		
		<tr>
			 <td colspan="4"  style="text-align:center;height:35px;" >
	           <input type="button" value="确定" id="btn1" class="btn-normal"/>
	         </td>
		</tr>
		
	 </table>
	 <div  id="wait" style="display:none; text-align:center;" >
		<span ><font color="red"> 正在处理中，请耐心等候...</font></span>
	</div>
</div>
</body>
</html>